//
//  ChartingTop2CollectionViewCell.m
//  intelligent
//
//  Created by 甘世清 on 2024/3/1.
//

#import "ChartingTop2CollectionViewCell.h"

@implementation ChartingTop2CollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    self.contentView.layer.cornerRadius = 8;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.clipsToBounds = YES;
    self.contentView.backgroundColor = SQColor(@"#EEEEEE");
    [self.contentView addSubview:self.bgImage];
    [self.bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
}
- (void)setModel:(HotModel *)model{
    [super setModel:model];
    self.nameLabel.text = model.name;
    if (model.isSeleted) {
        self.bgImage.hidden = NO;
    } else {
        self.bgImage.hidden = YES;
    }
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(14);
        _nameLabel.textColor = SQColor333333;
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        _nameLabel.backgroundColor = UIColor.clearColor;
    }
    return _nameLabel;
}
- (UIImageView *)bgImage {
    if (!_bgImage) {
        _bgImage = [[UIImageView alloc]init];
        _bgImage.image = SQGetImage(@"热门");
        _bgImage.contentMode = UIViewContentModeScaleAspectFill;
        _bgImage.hidden = YES;
    }
    return _bgImage;
}
@end
